<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
		window.onload = function() {
			var oDiv = document.getElementById('div1');
			var oA = document.getElementById('link');
			oDiv.style.color = "red";
			oDiv.style.fontSize = "20px";

			var sId = oDiv.id;
			// alert(sId)

			oA.href = "http://www.baidu.com";
			oA.title = "这是去到百度网的链接";

			var oDiv2 = document.getElementById('div2');
			oDiv2.className = "box2";
		}
	</script>
	<style>
		.box {
			font-size: 20px;
			color: gold;
		}

		.box2 {
			font-size: 30px;
			color: pink;
		}
	</style>
</head>
<body>
	<div id="div1">这是一个div元素</div>
	<a href="#" class="" id="link">这是一个链接</a>
	<div class="box" id="div2">这是第二个div</div>
</body>
</html>